package cn.iocoder.yudao.module.system.dal.mysql.user;


import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SystemCustomerService;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface CustomerServiceMapper extends BaseMapperX<SystemCustomerService> {
    /**
     * 根据父级id查询客服信息,状态为在线
     * @param parentId
     * 返回正在回复客户数量少的客服
     */
    default SystemCustomerService selectByParentId(Long parentId) {
        LambdaQueryWrapperX<SystemCustomerService> queryWrapper = new LambdaQueryWrapperX<>();
        queryWrapper.eq(SystemCustomerService::getParentId, parentId);
        queryWrapper.eq(SystemCustomerService::getStatus, 0);
        queryWrapper.orderByAsc(SystemCustomerService::getServiceNumber);
        return selectOne(queryWrapper);
    }
}
